import hashlib
import math


def Md5(text, salt=None):
    """ md5 encryption """
    t = hashlib.md5()
    if type(text) != bytes:
        text = str(text).encode()
    t.update(text)
    if salt:
        if type(salt) != bytes:
            salt = str(salt).encode()
        t.update(salt)
    return t.hexdigest()


def Calculate_coordinates(lon_start, lat_start, distance):
    """ Convert distance to the difference between longitude and latitude (angle) """
    lat_delta = distance / 111000
    lon_delta = distance / (111000 * math.cos(math.radians(lat_start)))

    # Calculate the maximum and minimum latitude and longitude
    lat_max = lat_start + lat_delta
    lat_min = lat_start - lat_delta
    lon_max = lon_start + lon_delta
    lon_min = lon_start - lon_delta

    return lon_min, lon_max, lat_min, lat_max
